
#ifndef	LEVEL_SLIDE_OBJECT_HPP
#define	LEVEL_SLIDE_OBJECT_HPP

#include <level/slide/object/object_fwd.hpp>
#include <drawables/animation.hpp>
#include <sfml/helper.hpp>
#include <physics/physics.hpp>
#include <physics/user_data/user_data.hpp>
#include <rapidxml/rapidxml.hpp>
#include <utils/from_string.hpp>

class object
{
public:

	virtual ~object( );
	virtual void step( float delta_time );
	virtual void draw( );
	body_ptr body( ) const
	{
		return m_body;
	}

protected:

	object( );

	template < typename TType >
	TType read_from_node( rapidxml::xml_node<> * node, TType const & default_ )
	{
		if ( node == nullptr )
		{
			return default_;
		}

		try
		{
			return from_string<TType>( node->value( ) );
		}
		catch ( std::exception const & )
		{
			return default_;
		}
	}

	void add_shape( rapidxml::xml_node<> * shape_node );
	void load_animation( rapidxml::xml_node<> * body_node );
	void assign_user_data( );

	drawable_ptr m_animation;
	body_ptr m_body;
	boost::scoped_ptr<fire_event_user_data> m_user_data;
};

#endif	//LEVEL_SLIDE_OBJECT_HPP
